package com.caochenlei.visitor;

import java.util.ArrayList;
import java.util.List;

public class ObjectStructure {
    private List<ComputerPart> computerParts = new ArrayList<>();

    public void attach(ComputerPart computerPart) {
        computerParts.add(computerPart);
    }

    public void detach(ComputerPart computerPart) {
        computerParts.remove(computerPart);
    }

    public void display(ComputerPartVisitor computerPartVisitor) {
        for (ComputerPart computerPart : computerParts) {
            computerPart.accept(computerPartVisitor);
        }
    }
}
